package com.elitedatai.mchtest.flyer.model.entity;


import com.elitedatai.mchtest.common.model.BaseEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 无人机飞手实体类
 * 该类用于表示无人机飞手的相关信息，包括基本信息、资质信息、飞行统计和安全评级等
 */
@Table(name = "flyer")
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Entity
public class Flyer extends BaseEntity implements Serializable {

    /**
     * 飞手ID - 唯一标识符
     */
    @Column(name = "flyer_id", nullable = false, unique = true)
    private String flyerId;

    /**
     * 飞手姓名
     */
    @Column(name = "flyer_name", nullable = false)
    private String flyerName;

    /**
     * 联系电话
     */
    @Column(name = "phone")
    private String phone;

    /**
     * 电子邮箱
     */
    @Column(name = "email")
    private String email;

    /**
     * 状态 (在职、离职、飞行中、空闲)
     */
    @Column(name = "status")
    private Integer status;

    /**
     * 资质类型 (如：AOPA、UTC、ASFC等)
     */
    @Column(name = "qualification_type")
    private String qualificationType;

    /**
     * 资质证书编号
     */
    @Column(name = "certificate_number")
    private String certificateNumber;

    /**
     * 资质有效期
     */
    @Column(name = "qualification_expiry")
    private LocalDateTime qualificationExpiry;

    /**
     * 认证等级 (如：初级、中级、高级、教员等)
     */
    @Column(name = "certification_level")
    private String certificationLevel;

    /**
     * 累计飞行时长（小时）
     */
    @Column(name = "total_flight_hours", precision = 10, scale = 2)
    private BigDecimal totalFlightHours;

    /**
     * 累计任务次数
     */
    @Column(name = "total_missions")
    private Integer totalMissions;

    /**
     * 安全评级
     * 根据事故次数占累计任务次数的比例获得评级
     * 比例每满20%扣一分，满分5分，不满一分的再次按比例扣，可包含两位小数
     */
    @Column(name = "safety_rating", precision = 3, scale = 2)
    private BigDecimal safetyRating;

    /**
     * 事故次数
     */
    @Column(name = "accident_count")
    private Integer accidentCount;

    /**
     * 违规次数
     */
    @Column(name = "violation_count")
    private Integer violationCount;

}
